<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
    <script src="./rollups/aes.js?v=1.1"></script>
    <script src="./components/mode-ecb.js?v=1.0"></script>
    <script src="./components/pad-nopadding.js?v=1.0"></script>
    <script>

        var key_Int = new Int8Array([32,87,47,82,54,75,63,71,48,80,65,88,17,99,45,43]);
        var keyBytes = Int8parse(key_Int); // 数据解析


        function Encrypt(){  
            var srcs_Int = new Int8Array([16,1,4,59,80,65,245,0,0,0,0,0,0,0,0,0]);
            var srcsBytes = Int8parse(srcs_Int); // 数据解析
            var encrypted = CryptoJS.AES.encrypt(srcsBytes, keyBytes, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.NoPadding}); 
            return encrypted.toString();  
        }  
        function Decrypt(word){  

            var decrypt = CryptoJS.AES.decrypt(word, keyBytes, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.NoPadding});  
            return CryptoJS.enc.Hex.stringify(decrypt).toString();  
        }  

        var encrypted = Encrypt()
        console.log(encrypted)
        console.log(hexToBytes(Decrypt(encrypted)))
        

        var uint8Arr = base64ToBytes(encrypted.toString());

        var intArray = new Int8Array( uint8Arr );
      

        function getCharCode(codeString)
        {
            var result = "";
            var codeStringArray = codeString.split(",");
            for(var i = 0;i<codeStringArray.length;i++)
            {
                result += String.fromCharCode(codeStringArray[i]);

            }
            return result;
        }

        function bytesToHex(bytes) {
            for (var hex = [], i = 0; i < bytes.length; i++) {
                hex.push((bytes[i] >>> 4).toString(16));
                hex.push((bytes[i] & 0xF).toString(16));
            }
            return hex.join("");
        }
        function base64ToBytes(base64) {

            // Use browser-native function if it exists
            var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

            // Remove non-base-64 characters
            base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");

            for (var bytes = [], i = 0, imod4 = 0; i < base64.length; imod4 = ++i % 4) {
                if (imod4 == 0) continue;
                bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2)) |
                           (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));
            }

            return bytes;

        }
        function hexToBytes(hex) {
            for (var bytes = [], c = 0; c < hex.length; c += 2)
                bytes.push(parseInt(hex.substr(c, 2), 16));
            return bytes;
        }
        function bytesToBase64(bytes) {

            // Use browser-native function if it exists
            var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

            for(var base64 = [], i = 0; i < bytes.length; i += 3) {
                var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
                for (var j = 0; j < 4; j++) {
                    if (i * 8 + j * 6 <= bytes.length * 8)
                        base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));
                    else base64.push("=");
                }
            }

            return base64.join("");

        }

        
        function Int8parse(u8arr) {
            // Shortcut
            var len = u8arr.length;

            // Convert
            var words = [];
            for (var i = 0; i < len; i++) {
                words[i >>> 2] |= (u8arr[i] & 0xff) << (24 - (i % 4) * 8);
            }

            return CryptoJS.lib.WordArray.create(words, len);
        }
        

    </script>
</body>
</html>
